#!/usr/bin/env python
#-*-coding:utf-8-*-
from urllib import request,parse
from  http import cookiejar
#http://www.xicidaili.com/ 西刺代理
if __name__=='__main__':

    url='http://www.whatismyip.com.tw/'
    head={'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'}
    reqs = request.Request(url=url, headers=head)
    req = request.urlopen(reqs, timeout=10)
    htmls = req.read().decode('utf-8')
    print(htmls + "\n\n\n")

   # proxy={'http':'114.215.95.188:3128'}
    proxy={'http':'122.114.31.177:808'}
    proxy_support=request.ProxyHandler(proxy)
    opener=request.build_opener(proxy_support)
    opener.addheaders=[('User-Agent','Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36')]
    #request.install_opener(opener)
    req=opener.open(url)

    #req=request.urlopen(url=url)
    html=req.read().decode('utf-8')
    print(html)
    #request.install_opener(request.build_opener(request.ProxyHandler({})))

